home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 27 / CU Amiga Magazine's Super CD-ROM 27 (1998)(EMAP Images)(GB)[!][issue 1998-10].iso / CUCD / Programming / BlitzList / BlitzListFiles / BlitzC2P.lha / programming / blitz2 / programs / c2pGeneric.ascii < prev    next >
Encoding:
Text File  |  1998-07-27  |  7.8 KB  |  492 lines

  1. WBStartup
  2. NoCli
  3.  
  4. ; 040/25 results:
  5.  
  6. ; 320x200 @42fps DoublePAL or 44fps PAL
  7. ; 320x256 @31fps DoublePAL or 34fps PAL
  8. ; 320x240 @33.7fps DoublePAL or 36.5fps PAL
  9.  
  10. #c2pBPLX=320
  11. #c2pBPLY=256
  12. #c2pBPLSIZE=(#c2pBPLX*#c2pBPLY)/8
  13.  
  14. #scrwidth=#c2pBPLX
  15. #scrheight=#c2pBPLY
  16. #screensize=#scrwidth*#scrheight
  17.  
  18. ; 060 friendly version
  19. ;       modulo  max res fscreen compu
  20. ; c2p1x1_8_c5     no  320x256?  no  030
  21.  
  22. Statement c2pGenericInit{A.l,B.l}
  23.  
  24.   ;A.l=d0=Width.w
  25.   ;B.l=d1=Height.w
  26.  
  27. ; d0.w  chunkyx [chunky-pixels]
  28. ; d1.w  chunkyy [chunky-pixels]
  29. ; d3.w  scroffsy [screen-pixels]
  30.  
  31.   MOVEQ.l #0,d3 ; Y offset
  32.  
  33. c2p1x1_8_c5_init
  34.   LEA c2p_datanew(pc),a0
  35.   ANDI.l  #$ffff,d0
  36.   MULU.w  d0,d3
  37.   LSR.l #3,d3
  38.   MOVE.l  d3,c2p_scroffs-c2p_data(a0)
  39.   MULU.w  d0,d1
  40.   MOVE.l  d1,c2p_pixels-c2p_data(a0)
  41. AsmExit
  42. End Statement
  43.  
  44. Statement c2pGeneric{A.l,B.l}
  45.  
  46.   MOVE.l  d0,a0 ; Chunky
  47.   MOVE.l  d1,a1 ; Planar
  48.  
  49. ; a0  c2pscreen
  50. ; a1  bitplanes
  51.  
  52. c2p1x1_8_c5
  53.   MOVEM.l a3-a6,-(a7)
  54.  
  55.   MOVEM.l a0-a1,-(a7)
  56.   LEA c2p_datanew,a0
  57.   LEA c2p_data,a1
  58.   MOVEQ #16-1,d0
  59. _c2pcopy: MOVE.l  (a0)+,(a1)+
  60.   DBF d0,_c2pcopy
  61.   MOVEM.l (a7)+,a0-a1
  62.  
  63.   LEA c2p_data(pc),a2
  64.  
  65.   MOVE.l  #$33333333,d5
  66.   MOVE.l  #$55555555,a6
  67.  
  68.   ADD.w #c2pBPLSIZE,a1
  69.   ADD.l c2p_scroffs-c2p_data(a2),a1
  70.  
  71.   MOVE.l  c2p_pixels-c2p_data(a2),a2
  72.   ADD.l a0,a2
  73.   CMP.l a0,a2
  74.   BEQ _none
  75.  
  76.   MOVEM.l a0-a1,-(a7)
  77.  
  78.   MOVE.l  (a0)+,d0
  79.   MOVE.l  (a0)+,d2
  80.   MOVE.l  (a0)+,d1
  81.   MOVE.l  (a0)+,d3
  82.  
  83.   MOVE.l  #$0f0f0f0f,d4   ; Merge 4x1, part 1
  84.   AND.l d4,d0
  85.   AND.l d4,d1
  86.   AND.l d4,d2
  87.   AND.l d4,d3
  88.   LSL.l #4,d0
  89.   LSL.l #4,d1
  90.   OR.l  d2,d0
  91.   OR.l  d3,d1
  92.  
  93.   MOVE.l  (a0)+,d2
  94.   MOVE.l  (a0)+,d6
  95.   MOVE.l  (a0)+,d3
  96.   MOVE.l  (a0)+,d7
  97.  
  98.   AND.l d4,d2     ; Merge 4x1, part 2
  99.   AND.l d4,d6
  100.   AND.l d4,d3
  101.   AND.l d4,d7
  102.   LSL.l #4,d2
  103.   LSL.l #4,d3
  104.   OR.l  d6,d2
  105.   OR.l  d7,d3
  106.  
  107.   MOVE.w  d2,d6     ; Swap 16x2
  108.   MOVE.w  d3,d7
  109.   MOVE.w  d0,d2
  110.   MOVE.w  d1,d3
  111.   SWAP  d2
  112.   SWAP  d3
  113.   MOVE.w  d2,d0
  114.   MOVE.w  d3,d1
  115.   MOVE.w  d6,d2
  116.   MOVE.w  d7,d3
  117.  
  118.   MOVE.l  d2,d6     ; Swap 2x2
  119.   MOVE.l  d3,d7
  120.   LSR.l #2,d6
  121.   LSR.l #2,d7
  122.   EOR.l d0,d6
  123.   EOR.l d1,d7
  124.   AND.l d5,d6
  125.   AND.l d5,d7
  126.   EOR.l d6,d0
  127.   EOR.l d7,d1
  128.   LSL.l #2,d6
  129.   LSL.l #2,d7
  130.   EOR.l d6,d2
  131.   EOR.l d7,d3
  132.  
  133.   MOVE.l  #$00ff00ff,d4
  134.   MOVE.l  d1,d6     ; Swap 8x1
  135.   MOVE.l  d3,d7
  136.   LSR.l #8,d6
  137.   LSR.l #8,d7
  138.   EOR.l d0,d6
  139.   EOR.l d2,d7
  140.   BRA _start1
  141. _x1
  142.   MOVE.l  (a0)+,d0
  143.   MOVE.l  (a0)+,d2
  144.   MOVE.l  (a0)+,d1
  145.   MOVE.l  (a0)+,d3
  146.   MOVE.l  d7,-c2pBPLSIZE(a1)
  147.  
  148.   MOVE.l  #$0f0f0f0f,d4   ; Merge 4x1, part 1
  149.   AND.l d4,d0
  150.   AND.l d4,d1
  151.   AND.l d4,d2
  152.   AND.l d4,d3
  153.   LSL.l #4,d0
  154.   LSL.l #4,d1
  155.   OR.l  d2,d0
  156.   OR.l  d3,d1
  157.  
  158.   MOVE.l  (a0)+,d2
  159.   MOVE.l  (a0)+,d6
  160.   MOVE.l  (a0)+,d3
  161.   MOVE.l  (a0)+,d7
  162.   MOVE.l  a3,c2pBPLSIZE(a1)
  163.  
  164.   AND.l d4,d2     ; Merge 4x1, part 2
  165.   AND.l d4,d6
  166.   AND.l d4,d3
  167.   AND.l d4,d7
  168.   LSL.l #4,d2
  169.   LSL.l #4,d3
  170.   OR.l  d6,d2
  171.   OR.l  d7,d3
  172.  
  173.   MOVE.w  d2,d6     ; Swap 16x2
  174.   MOVE.w  d3,d7
  175.   MOVE.w  d0,d2
  176.   MOVE.w  d1,d3
  177.   SWAP  d2
  178.   SWAP  d3
  179.   MOVE.w  d2,d0
  180.   MOVE.w  d3,d1
  181.   MOVE.w  d6,d2
  182.   MOVE.w  d7,d3
  183.   MOVE.l  a4,c2pBPLSIZE*2(a1)
  184.  
  185.   MOVE.l  d2,d6     ; Swap 2x2
  186.   MOVE.l  d3,d7
  187.   LSR.l #2,d6
  188.   LSR.l #2,d7
  189.   EOR.l d0,d6
  190.   EOR.l d1,d7
  191.   AND.l d5,d6
  192.   AND.l d5,d7
  193.   EOR.l d6,d0
  194.   EOR.l d7,d1
  195.   LSL.l #2,d6
  196.   LSL.l #2,d7
  197.   EOR.l d6,d2
  198.   EOR.l d7,d3
  199.  
  200.   MOVE.l  #$00ff00ff,d4
  201.   MOVE.l  d1,d6     ; Swap 8x1
  202.   MOVE.l  d3,d7
  203.   LSR.l #8,d6
  204.   LSR.l #8,d7
  205.   EOR.l d0,d6
  206.   EOR.l d2,d7
  207.   MOVE.l  a5,(a1)+
  208. _start1
  209.   AND.l d4,d6
  210.   AND.l d4,d7
  211.   EOR.l d6,d0
  212.   EOR.l d7,d2
  213.   LSL.l #8,d6
  214.   LSL.l #8,d7
  215.   EOR.l d6,d1
  216.   EOR.l d7,d3
  217.  
  218.   MOVE.l  a6,d4
  219.   MOVE.l  d1,d6     ; Swap 1x1
  220.   MOVE.l  d3,d7
  221.   LSR.l #1,d6
  222.   LSR.l #1,d7
  223.   EOR.l d0,d6
  224.   EOR.l d2,d7
  225.   AND.l d4,d6
  226.   AND.l d4,d7
  227.   EOR.l d6,d0
  228.   EOR.l d7,d2
  229.   ADD.l d6,d6
  230.   ADD.l d7,d7
  231.   EOR.l d1,d6
  232.   EOR.l d3,d7
  233.  
  234.   MOVE.l  d0,a4
  235.   MOVE.l  d2,a5
  236.   MOVE.l  d6,a3
  237.  
  238.   CMPA.l  a0,a2
  239.   BNE _x1
  240.   MOVE.l  d7,-c2pBPLSIZE(a1)
  241.   MOVE.l  a3,c2pBPLSIZE(a1)
  242.   MOVE.l  a4,c2pBPLSIZE*2(a1)
  243.   MOVE.l  a5,(a1)+
  244.  
  245.   MOVEM.l (a7)+,a0-a1
  246.   ADD.l #c2pBPLSIZE*4,a1
  247.  
  248.   MOVE.l  (a0)+,d0
  249.   MOVE.l  (a0)+,d2
  250.   MOVE.l  (a0)+,d1
  251.   MOVE.l  (a0)+,d3
  252.  
  253.   MOVE.l  #$f0f0f0f0,d4   ; Merge 4x1, part 1
  254.   AND.l d4,d0
  255.   AND.l d4,d1
  256.   AND.l d4,d2
  257.   AND.l d4,d3
  258.   LSR.l #4,d2
  259.   LSR.l #4,d3
  260.   OR.l  d2,d0
  261.   OR.l  d3,d1
  262.  
  263.   MOVE.l  (a0)+,d2
  264.   MOVE.l  (a0)+,d6
  265.   MOVE.l  (a0)+,d3
  266.   MOVE.l  (a0)+,d7
  267.  
  268.   AND.l d4,d2     ; Merge 4x1, part 2
  269.   AND.l d4,d6
  270.   AND.l d4,d3
  271.   AND.l d4,d7
  272.   LSR.l #4,d6
  273.   LSR.l #4,d7
  274.   OR.l  d6,d2
  275.   OR.l  d7,d3
  276.  
  277.   MOVE.w  d2,d6     ; Swap 16x2
  278.   MOVE.w  d3,d7
  279.   MOVE.w  d0,d2
  280.   MOVE.w  d1,d3
  281.   SWAP  d2
  282.   SWAP  d3
  283.   MOVE.w  d2,d0
  284.   MOVE.w  d3,d1
  285.   MOVE.w  d6,d2
  286.   MOVE.w  d7,d3
  287.  
  288.   MOVE.l  d2,d6     ; Swap 2x2
  289.   MOVE.l  d3,d7
  290.   LSR.l #2,d6
  291.   LSR.l #2,d7
  292.   EOR.l d0,d6
  293.   EOR.l d1,d7
  294.   AND.l d5,d6
  295.   AND.l d5,d7
  296.   EOR.l d6,d0
  297.   EOR.l d7,d1
  298.   LSL.l #2,d6
  299.   LSL.l #2,d7
  300.   EOR.l d6,d2
  301.   EOR.l d7,d3
  302.  
  303.   MOVE.l  #$00ff00ff,d4
  304.   MOVE.l  d1,d6     ; Swap 8x1
  305.   MOVE.l  d3,d7
  306.   LSR.l #8,d6
  307.   LSR.l #8,d7
  308.   EOR.l d0,d6
  309.   EOR.l d2,d7
  310.   BRA _start2
  311. _x2
  312.   MOVE.l  (a0)+,d0
  313.   MOVE.l  (a0)+,d2
  314.   MOVE.l  (a0)+,d1
  315.   MOVE.l  (a0)+,d3
  316.   MOVE.l  d7,-c2pBPLSIZE(a1)
  317.  
  318.   MOVE.l  #$f0f0f0f0,d4   ; Merge 4x1, part 1
  319.   AND.l d4,d0
  320.   AND.l d4,d1
  321.   AND.l d4,d2
  322.   AND.l d4,d3
  323.   LSR.l #4,d2
  324.   LSR.l #4,d3
  325.   OR.l  d2,d0
  326.   OR.l  d3,d1
  327.  
  328.   MOVE.l  (a0)+,d2
  329.   MOVE.l  (a0)+,d6
  330.   MOVE.l  (a0)+,d3
  331.   MOVE.l  (a0)+,d7
  332.   MOVE.l  a3,c2pBPLSIZE(a1)
  333.  
  334.   AND.l d4,d2     ; Merge 4x1, part 2
  335.   AND.l d4,d6
  336.   AND.l d4,d3
  337.   AND.l d4,d7
  338.   LSR.l #4,d6
  339.   LSR.l #4,d7
  340.   OR.l  d6,d2
  341.   OR.l  d7,d3
  342.  
  343.   MOVE.w  d2,d6     ; Swap 16x2
  344.   MOVE.w  d3,d7
  345.   MOVE.w  d0,d2
  346.   MOVE.w  d1,d3
  347.   SWAP  d2
  348.   SWAP  d3
  349.   MOVE.w  d2,d0
  350.   MOVE.w  d3,d1
  351.   MOVE.w  d6,d2
  352.   MOVE.w  d7,d3
  353.   MOVE.l  a4,c2pBPLSIZE*2(a1)
  354.  
  355.   MOVE.l  d2,d6     ; Swap 2x2
  356.   MOVE.l  d3,d7
  357.   LSR.l #2,d6
  358.   LSR.l #2,d7
  359.   EOR.l d0,d6
  360.   EOR.l d1,d7
  361.   AND.l d5,d6
  362.   AND.l d5,d7
  363.   EOR.l d6,d0
  364.   EOR.l d7,d1
  365.   LSL.l #2,d6
  366.   LSL.l #2,d7
  367.   EOR.l d6,d2
  368.   EOR.l d7,d3
  369.  
  370.   MOVE.l  #$00ff00ff,d4
  371.   MOVE.l  d1,d6     ; Swap 8x1
  372.   MOVE.l  d3,d7
  373.   LSR.l #8,d6
  374.   LSR.l #8,d7
  375.   EOR.l d0,d6
  376.   EOR.l d2,d7
  377.   MOVE.l  a5,(a1)+
  378. _start2
  379.   AND.l d4,d6
  380.   AND.l d4,d7
  381.   EOR.l d6,d0
  382.   EOR.l d7,d2
  383.   LSL.l #8,d6
  384.   LSL.l #8,d7
  385.   EOR.l d6,d1
  386.   EOR.l d7,d3
  387.  
  388.   MOVE.l  a6,d4
  389.   MOVE.l  d1,d6     ; Swap 1x1
  390.   MOVE.l  d3,d7
  391.   LSR.l #1,d6
  392.   LSR.l #1,d7
  393.   EOR.l d0,d6
  394.   EOR.l d2,d7
  395.   AND.l d4,d6
  396.   AND.l d4,d7
  397.   EOR.l d6,d0
  398.   EOR.l d7,d2
  399.   ADD.l d6,d6
  400.   ADD.l d7,d7
  401.   EOR.l d1,d6
  402.   EOR.l d3,d7
  403.  
  404.   MOVE.l  d0,a4
  405.   MOVE.l  d2,a5
  406.   MOVE.l  d6,a3
  407.  
  408.   CMPA.l  a0,a2
  409.   BNE _x2
  410.   MOVE.l  d7,-c2pBPLSIZE(a1)
  411.   MOVE.l  a3,c2pBPLSIZE(a1)
  412.   MOVE.l  a4,c2pBPLSIZE*2(a1)
  413.   MOVE.l  a5,(a1)+
  414.  
  415. _none
  416.   MOVEM.l (a7)+,a3-a6
  417.   AsmExit
  418.  
  419.   Even4
  420. c2p_data
  421. c2p_screen: Dc.l 0
  422. c2p_scroffs: Dc.l 0
  423. c2p_scroffs2: Dc.l 0
  424. c2p_c2pBPLSIZE: Dc.l 0
  425. c2p_pixels: Dc.l 0
  426. c2p_pixels2: Dc.l 0
  427. c2p_pixels4: Dc.l 0
  428. c2p_pixels8: Dc.l 0
  429. c2p_pixels16: Dc.l 0
  430. c2p_chunkyx16: Dc.w 0
  431. c2p_chunkyx32: Dc.w 0
  432. c2p_chunkyy: Dc.w 0
  433. c2p_rowmod: Dc.w 0
  434.   Ds.l  16
  435.   Even4
  436. c2p_datanew
  437.   Ds.l  16
  438. End Statement
  439.  
  440.  
  441.  
  442. .blitzprogram
  443. ; Setup
  444. InitBank 0,(#scrwidth*#scrheight)+1000,2|65536 ; Chipram planar buffer
  445. CludgeBitMap 0,#scrwidth,#scrheight,8,Bank(0)
  446. InitPalette 0,256
  447. For c=0 To 255
  448.   AGAPalRGB 0,c,Rnd(c),Rnd(c),Rnd(c)
  449. Next c
  450. AGAPalRGB 0,0,0,0,0
  451. Screen 0,0,0,#scrwidth,#scrheight,8,0,"c2p test",0,0,0
  452. Use Palette 0
  453. VWait 50
  454. baseaddress1.l=AllocMem(#scrwidth*#scrheight,$10000) ; Fastram chunky buffer
  455.  
  456. ; Put something into the chunky buffer so we can see it working
  457. GetReg a0,baseaddress1
  458. MOVE.l  #0,d0
  459. MOVE.l  #screensize-1,d1
  460. cloop
  461.   MOVE.b  d0,(a0)+
  462.   ADDQ.l  #1,d0
  463.   SUBQ.l  #1,d1
  464.   TST.l   d1
  465.   BLT     done
  466.   BRA     cloop
  467. done
  468.  
  469. ; Do the c2p test
  470. c2pGenericInit{#scrwidth,#scrheight}
  471. VWait 20
  472. Forbid_
  473. VWait
  474. ResetTimer
  475. For time=1 To 800
  476.   c2pGeneric{baseaddress1,Bank(0)} ; Convert chunky to planar
  477. Next time
  478. t=Ticks
  479. VWait 2 : Permit_
  480. VWait 20
  481. FindScreen 0
  482. Window 0,0,11,640,100,0,"Test results for c2p",0,0
  483. WindowOutput 0
  484. NPrint "Routine performed @ ",50/(t/800),"fps - ",t," ticks"
  485. NPrint " "
  486. NPrint "Press mousebutton..."
  487. Free Screen 0
  488. MouseWait
  489. Free Window 0
  490. End
  491.  
  492.